package com.kly.user.rulePolicy.enums;

import java.io.Serializable;

public enum RuleComposeEnum implements Serializable {
    /**
     * 规则的组合方式:首次匹配|最坏匹配
     */

    FIRST, WORST;


    public static RuleComposeEnum transformByType(Integer type) {
        for (RuleComposeEnum ruleComposeEnum : RuleComposeEnum.values()) {
            if (ruleComposeEnum.ordinal() + 1 == type) {
                return ruleComposeEnum;
            }
        }
        return null;
    }

    public static RuleComposeEnum transformByName(String name) {
        if (RuleComposeEnum.WORST.name().equalsIgnoreCase(name)) {
            return RuleComposeEnum.WORST;
        } else if (RuleComposeEnum.FIRST.name().equalsIgnoreCase(name)) {
            return RuleComposeEnum.FIRST;
        } else {
            return null;
        }
    }

    public static void main(String[] args) {
        RuleComposeEnum ruleComposeEnum = transformByType(2);
        System.out.println();
    }
}
